package com.inspur.gs.sbssdl.sbwhgl.sbwhby.sbwhby.front.byjhpzlist_frm.voactions;
import com.inspur.edp.bef.api.lcp.ILcpFactory;
import com.inspur.edp.bef.api.lcp.IStandardLcp;
import com.inspur.edp.bef.api.services.IBefSessionManager;
import com.inspur.edp.bff.spi.*;
import com.inspur.edp.bef.api.action.*;
import com.inspur.edp.cef.entity.entity.IEntityDataCollection;
import io.iec.edp.caf.commons.utils.SpringBeanUtils;

public class isbypzglVOAction extends AbstractFSAction<VoidActionResult> {

	private String[] ids;
	public isbypzglVOAction(String[] ids) {

		this.ids = ids;
	}
	@Override
	public void execute() {
		SpringBeanUtils.getBean(IBefSessionManager.class).createSession();
		try {
			ILcpFactory iLcpFactory = SpringBeanUtils.getBean(ILcpFactory.class);
			String djid = "db558bb5-532f-430d-b610-13f9fc5835bd";
			IStandardLcp djlcp = iLcpFactory.createLcpByBEId(djid);
			for (String mainid : ids) {
				IEntityDataCollection sbdjpzmx = djlcp.retrieve(mainid).getData().getChilds().get("ybgl");
				if (!sbdjpzmx.isEmpty()){
					throw new RuntimeException("选择的设备已有一级保养配置");
				}
			}
		} finally {
			SpringBeanUtils.getBean(IBefSessionManager.class).closeCurrentSession();
		}
	}
}
